{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e030f292-8c50-4aac-b06a-074b7d1c63d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "501:[9000, 9500, 9200, 9233.0]\n",
      "502:[8000, 8500, 8200, 8233.0]\n",
      "503:[7000, 7500, 7200, 7233.0]\n"
     ]
    }
   ],
   "source": [
    "salary = {}\n",
    "fi = open(\"data.txt\",'r',encoding='utf-8')\n",
    "for item in fi:\n",
    "    stud = eval(item )\n",
    "    sKeyValue = stud.items()\n",
    "    skey = ''\n",
    "    svalue = []\n",
    "    for it in sKeyValue:\n",
    "        if it[0] =='sid':\n",
    "            skey = it[1]\n",
    "        else:\n",
    "            svalue.append(it[1])\n",
    "    else:   \n",
    "        svalue.append(round(sum(svalue)/len(svalue),0))\n",
    "    salary[skey] = svalue \n",
    "fi.close()\n",
    "so = list(salary.items())\n",
    "so.sort(key = lambda x:x[0],reverse = False)\n",
    "for item in so:\n",
    "    print('{}:{}'.format(item[0],item[1]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1e8585b-71f8-4dea-8910-469f10e1d993",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
